import utils from '@/utils/utils';

export const onFunctionClick = (item, entry = 'index') => {
  if (item.url) {
    let url;
    console.log(url);
    console.log(entry);

    // #ifdef MP-ALIPAY
    url = item.url;
    // #endif

    // #ifndef MP-ALIPAY
    url = item.isWeb ? `/pages/web/index?url=${encodeURIComponent(item.url)}` : item.url;
    // #endif

    // TODO 业务逻辑
  } else if (item.projectId) {
    // 跳转小程序
    uni.navigateToMinProgram({
      appId: item.projectId,
      extraData: {},
      success() {
        item.statKey && status(`resource.${item.statKey}`);
      },
      fail() {
        utils.toast('请稍后重试！');
      },
    });
  } else {
    utils.toast('功能开发中...');
  }
};

export const functions = {
  bookingRegister: {
    name: '注册预约',
    statKey: 'pre-booking',
    indexIcon: './static/home-selected.png',
    icon: '',
    url: '/pages/more/me/index',
  },
  isvBooking: {
    name: '注册预约',
    statKey: 'pre-booking',
    indexIcon: './static/home-selected.png',
    icon: '',
    // #ifdef MP-ALIPAY
    url: '/pages/more/me/index',
    // #endif
  },
  care: {
    name: '关心模块',
    statKey: 'care',
    icon: '',
    // ***.html
    url:
      'https://apply.hzxkctk.cn/apply/app/person/getIssue.do?id=1e578ee653dc46d38510caa71b380f23',
    isWeb: true,
  },
  birth: {
    name: '生日',
    statKey: 'birth',
    icon: '',
    projectId: '2018080808393939',
  },
};
